home *** CD-ROM | disk | FTP | other *** search
- Path: htsa.htsa.hva.nl!not-for-mail
- From: ferdinan@htsa.htsa.hva.nl (Ferdinand de Boevere)
- Newsgroups: comp.lang.c
- Subject: Re: Storing C Functions In An Array?
- Date: 28 Mar 1996 21:07:19 +0100
- Organization: Hogeschool van Amsterdam, The Netherlands, E.E. & C.S. Dept.
- Message-ID: <4jerhn$sc8@oege.htsa.hva.nl>
- References: <4jc1u7$5e9@infa.central.susx.ac.uk>
- NNTP-Posting-Host: oege.htsa.hva.nl
-
- In article <4jc1u7$5e9@infa.central.susx.ac.uk>,
- George Rattray <tepd6@central.susx.ac.uk> wrote:
- >Can someone help me, I'm trying to store functions in an array at
- >compile time. The following functions are defined as
- ^^^^^^^^
- declared
-
- > struct complex func(struct complex, CHNL);
- >
- >I want to store them in an array ch[N];
-
- Storing functions in an array is not possible.
- What you probably mean is storing 'pointers to function'
- in an array.
-
- >Therefor using the function with an index as
- >
- > ret = ch[0](x,chnl);
-
- This is allowed, with a function-pointer at position 0.
-
- More clearly, however, would be:
- ret = (*ch[0])(x, chnl);
-
- typedef struct complex (*Fp)(struct complex, CHNL);
- struct complex foo(struct complex, CHNL);
- Fp ch[N];
- ch[0] = foo; /* pointer to foo is at position 0 now */
-
- >Any help will be most appreciated, Thanks
- >
- >George
- >
-
- Ferdinand
-
-